//引入vue和vuex
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

export default new Vuex.Store({//全局变量定义
    state: {
        userName: "",
        userId:'',
        token:''
    },
    mutations: {
        login(state, user) {
            state.userName = user.userName;
            state.userId = user.userId;
            state.token = user.token;
        },
        logout(state) {
           state.userName = "";
           state.userId = '';
           state.token = '';
        }
    }
})